package com.ykt.converter;

import com.ykt.common.utils.UB;
import com.ykt.model.Service;
import com.ykt.vo.ServiceVo;

import java.util.ArrayList;
import java.util.List;

public class ServiceConverter extends BaseConverter {


    public static ServiceVo convert(Service model){
        if(model == null){
            return null;
        }

        ServiceVo vo = new ServiceVo();
        BaseConverter.convert(vo, model);

        vo.setServiceId(UB.i(model.get(Service.id), -1));
        vo.setOrderId(UB.i(model.get(Service.order_id), -1));
        vo.setUserId(UB.i(model.get(Service.user_id), -1));
        vo.setUserName("");
        vo.setServiceType(model.getStr(Service.service_type));
        vo.setReasons(model.getStr(Service.reasons));
        vo.setSummary(model.getStr(Service.summary));
        vo.setPic(model.getStr(Service.pic));
        vo.setStatus(model.getStr(Service.status));

        return vo;
    }

    public static List<ServiceVo> convert(List<Service> models){
        List<ServiceVo> vos = new ArrayList<>();
        if(models == null){
            return vos;
        }

        for (Service model : models) {
            vos.add(convert(model));
        }
        return vos;
    }

}
